﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AFCEPF.BankApplication.BLL
{
    /// <summary>
    /// Factory method to build AccountBase-derived
    /// classes..
    /// </summary>
    public static class AccountFactory
    {
        public const double MIN_DEPOSIT_FOR_SIMPLE = 100;
        public const double MIN_DEPOSIT_FOR_SILVER = 1000;
        public const double MIN_DEPOSIT_FOR_GOLD = 2000;


        /// <summary>
        /// Creates the account.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <param name="deposit">The deposit.</param>
        /// <returns>
        /// the correct account type based
        /// on the deposit.
        /// </returns>
        internal static AccountBase CreateAccount(Customer c, double deposit)
        {
            // We set this variable to null because 
            // we cannot return an unassigned variable.
            AccountBase result = null;

            if (deposit >= MIN_DEPOSIT_FOR_SIMPLE && 
                deposit <  MIN_DEPOSIT_FOR_SILVER)
            {
                result = new SimpleAccount(c, deposit);
            }
            else if (deposit >= MIN_DEPOSIT_FOR_SILVER && 
                deposit <  MIN_DEPOSIT_FOR_GOLD)
            {
                result = new SilverAccount(c, deposit);
            }
            else if (deposit >= MIN_DEPOSIT_FOR_GOLD)
            {
                result = new GoldAccount(c, deposit);
            }
            else
            {
                throw new InvalidDepositException("Invalid Deposit : " + deposit.ToString());
            }

            return result;
        }


 




    }
}
